package org.chapter.controller;

import org.chapter.model.Customer;
import org.chapter.service.CustomerService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * Created by Mr.no.
 * User:yangyun
 * Date:2017/9/24
 * Time:17:54
 */

/**
 * 进入客户列表页面
 */
@WebServlet("/customer")
public class Customerservlet extends HttpServlet {
    private CustomerService customerService;
    public void init() throws ServletException{
        customerService = new CustomerService();
    }
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<Customer> customerList = customerService.getCustomerList();
        req.setAttribute("customerList",customerList);
        req.getRequestDispatcher("/WEB-INF/view/customer.jsp").forward(req,resp);
    }
}
